home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASDEMO2 / EDITWIN2.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-18  |  9KB  |  266 lines

  1. program TypeOfEquipMaintainance;
  2.  
  3. uses Crt, Dos;
  4. type
  5.  
  6.    DateType = record
  7.                 Year:  string[2];
  8.                 Month: string[2];
  9.                 Day:   string[2];
  10.           end;
  11.    FileNameType = string[24];
  12.  
  13.    ModelNameType = string[12];
  14.    SNType = record
  15.                 FirstWord: string[2];
  16.                 SNKey:     string[8];
  17.                 SNRest:    string[6]
  18.             end;
  19.    PlatenNoType     = string[8];
  20.    CustomerCodeType = string[12];
  21.    LocationType     = string[20];
  22.    ContractorType   = string[20];
  23.    SetUpDateType    = DateType;
  24.  
  25.    AEquipmentRecordType = record
  26.                             ModelName:    ModelNameType;
  27.                             SN:           SNType;
  28.                             PlatenNo:     PlatenNoType;
  29.                             CustomerCode: CustomerCodeType;
  30.                             Location:     LocationType;
  31.                             Contractor:   ContractorType;
  32.                             SetUpDate:    SetUpDateType
  33.                          end;
  34.  
  35.    EquipmentFileType = file of AEquipmentRecordType;
  36.  
  37.    EquipPtrType = ^EquipNode;
  38.    EquipNode = record
  39.                   AData: AEquipmentRecordType;
  40.                end;
  41.    EquipPtrArrayType = array[1..100] of EquipPtrType;
  42.  
  43.    {---------------------}
  44.  
  45.    String50 = string[50];
  46.    String20 = string[20];
  47.  
  48.    AMaintenanceCardType = record
  49.                              CardDate: DateType;
  50.                              SNo:      SNType;
  51.                              Symptoms: String50;
  52.                              Process:  String50;
  53.                              Remark:   String50
  54.                           end;
  55.  
  56.    MaintenanceFileType = file of AMaintenanceCardType;
  57.  
  58.  
  59. var
  60.  
  61.    EquipFileVar: EquipmentFileType;
  62.    MaintFileVar: MaintenanceFileType;
  63.  
  64.    EquipFileName,
  65.    MaintFileName: FileNameType;
  66.  
  67.    EquipPtrArray: EquipPtrArrayType;
  68.    TotalEquipRecord: integer;
  69.  
  70.  
  71. procedure AssignFiles( var EquipFileName, MaintFileName: FileNameType );
  72.    const
  73.       TestEquipFileName = 'a:Equip';
  74.       TestMaintFileName = 'a:Maint';
  75.    begin
  76.  
  77.       EquipFileName := TestEquipFileName;
  78.       MaintFileName := TestMaintFileName;
  79.  
  80.       Assign( EquipFileVar, EquipFileName );
  81.       Assign( MaintFileVar, MaintFileName );
  82.  
  83.    end; { of proc OpenFiles }
  84.  
  85. procedure ReadEquipmentFile( var EquipPtrArray: EquipPtrArrayType;
  86.                              var TotalEquipRecord: integer );
  87.    var
  88.       Count: integer;
  89.       AEquipData: AEquipmentRecordType;
  90.    begin
  91.       Reset( EquipFileVar );
  92.       TotalEquipRecord :=  FileSize( EquipFileVar );
  93.       for Count := 1 to TotalEquipRecord do begin
  94.          Read( EquipFileVar, AEquipData );
  95.          New( EquipPtrArray[Count] );
  96.          EquipPtrArray[Count]^.AData := AEquipData;
  97.       end;
  98.       Close( EquipFileVar );
  99.    end;
  100.  
  101.  
  102. procedure DisplayTitle;
  103.    begin
  104.       writeln;
  105.       HighVideo;
  106.       writeln( ' NO MODEL    SERIAL NO       PLANTEN  CUSTOMER   LOCATION     CONTRACTOR DATE' );
  107.       NormVideo;
  108.    end; { of proc DisplayTitle }
  109.  
  110. {
  111. 0        1         2         3         4         5         6         7
  112. 1234567890123456789012345678901234567890123456789012345678901234567890123456789
  113.  NO MODEL    SERIAL NO       PLANTEN  CUSTOMER   LOCATION     CONTRACTOR DATE
  114. 123 12345678 12345678-123456 12345678 1234567890 123456789012 1234567890 123456
  115.  
  116.  
  117. 0        1         2         3         4         5         6         7
  118. 1234567890123456789012345678901234567890123456789012345678901234567890123456789
  119. ==============================================================================
  120. | RECORD NO  123            MODEL NO 12345678       SN     WP12345678-123456 |
  121. | CUSTOMER   123456789012   LOCATION 123456789012   PLATEN 12345678          |
  122. | CONTRACTOR 123456789012344567890              SETUP DATE XX/XX/XX          |
  123. ==============================================================================
  124. }
  125.  
  126. procedure SetWindow( X1, Y1, X2, Y2: integer );
  127.    const
  128.       UpLeftCorner    = #201;
  129.       HorzBar         = #205;
  130.       UpRightCorner   = #187;
  131.       VertBar         = #186;
  132.       LowLeftCorner   = #200;
  133.       LowRightCorner  = #188;
  134.    var
  135.       I: integer;
  136.    begin
  137.       HighVideo;
  138.       Window( 1, 1, 80, 25 );
  139.       GoToXY( X1-1, Y1-1 );
  140.       write( UpLeftCorner );
  141.       for I := X1 to X2 do
  142.          write( HorzBar );
  143.       write( UpRightCorner );
  144.       for I := Y1 to Y2 do begin
  145.          GoToXY( X1-1, I ); write( VertBar );
  146.          GoToXY( X2+1, I ); write( VertBar )
  147.       end;
  148.       GoToXY( X1-1, Y2+1 );
  149.       write( LowLeftCorner );
  150.       for I := X1 to X2 do
  151.          write( HorzBar );
  152.       write( LowRightCorner );
  153.       NormVideo;
  154.       Window( X1, Y1, X2, Y2 )
  155.    end; { of proc SetWindow }
  156.  
  157. procedure DisplayItemTitles;
  158.    const
  159.       X1 =  2;
  160.       Y1 = 22;
  161.       X2 = 78;
  162.       Y2 = 24;
  163.    begin
  164.       SetWindow( X1, Y1, X2, Y2 );
  165.       GotoXY( 1, 1 );
  166.       TextAttr := White;
  167.       LowVideo;
  168.       writeln( ' RECORD NO                 MODEL NO                SN               -');
  169.       writeln( ' CUSTOMER                  LOCATION                PLATEN' );
  170.       write(   ' CONTRACTOR                                    SETUP DATE   /  /' );
  171.       NormVideo;
  172.       Window( 1, 3, 80, 20 );
  173.    end;
  174.  
  175. procedure DisplayItemContents( RecordNo: integer; ARecord: AEquipmentRecordType );
  176.    type ItemPos = array[0..11] of array[0..1] of Byte;
  177.    const
  178.       XYPos: ItemPos = ((1,13),(1,37),(1,59),(1,61),(1,70),
  179.                         (2,13),(2,37),(2,59),
  180.                         (3,13),       (3,59),(3,62),(3,65));
  181.     begin
  182.        Window( 2, 22, 78, 24 );
  183.        HighVideo;
  184.        GotoXY( XYPos[0,1], XYPos[0,0] ); write( RecordNo );
  185.        with ARecord do begin
  186.          GotoXY( XYPos[1,1], XYPos[1,0] ); write( ModelName );
  187.          with SN do begin
  188.             GotoXY( XYPos[2,1], XYPos[2,0] ); write( FirstWord );
  189.             GotoXY( XYPos[3,1], XYPos[3,0] ); write( SNKey );
  190.             GotoXY( XYPos[4,1], XYPos[4,0] ); write( SNRest );
  191.          end;
  192.          GotoXY( XYPos[5,1], XYPos[5,0] ); write( PlatenNo );
  193.          GotoXY( XYPos[6,1], XYPos[6,0] ); write( CustomerCode );
  194.          GotoXY( XYPos[7,1], XYPos[7,0] ); write( Location );
  195.          GotoXY( XYPos[8,1], XYPos[8,0] ); write( Contractor );
  196.          with SetUpDate do begin
  197.             GotoXY( XYPos[ 9,1], XYPos[ 9,0] ); write( Year );
  198.             GotoXY( XYPos[10,1], XYPos[10,0] ); write( Month );
  199.             GotoXY( XYPos[11,1], XYPos[11,0] ); write( Day );
  200.          end;
  201.        end;
  202.        NormVideo;
  203.        Window( 1, 3, 80, 20 );
  204.     end;
  205.  
  206. procedure DisplayItem( Item: String20; Cnt: integer );
  207.    var Leng,
  208.        X: integer;
  209.    begin
  210.       Leng := Length( Item );
  211.       if Leng >= Cnt then begin
  212.          for X := 1 to Cnt do
  213.             write( Item[X] );
  214.          write( ' ' );
  215.       end else
  216.          write( Item, ' ':(Cnt-Leng+1) );
  217.    end; { of proc DisplayItem }
  218.  
  219. Procedure DisplayAEquip( NO: integer; AEquipRecord: AEquipmentRecordType );
  220.    var Item: String20;
  221.    begin
  222.       with AEquipRecord do begin
  223.          write( NO:3, ' ' );
  224.          Item := ModelName;    DisplayItem( Item, 8 );
  225.          write( SN.SNKey, '-', SN.SNRest, ' ' );
  226.          write( PlatenNo, ' ' );
  227.          Item := CustomerCode; DisplayItem( Item, 10 );
  228.          Item := Location;     DisplayItem( Item, 12 );
  229.          Item := Contractor;   DisplayItem( Item, 10 );
  230.          Item := SetUpDate.Year + SetUpDate.Month + SetUpDate.Day;
  231.                                DisplayItem( Item, 6 );
  232.       end
  233.    end;
  234.  
  235. procedure DisplayProcess( EquipPtrArray: EquipPtrArrayType;
  236.                           TotalEquipRecord: integer );
  237.    var AEquipRecord: AEquipmentRecordType;
  238.        RecordNo : integer;
  239.        OldPositionX,
  240.        OldPositionY: byte;
  241.        ch: char;
  242.        Test: integer;
  243.    begin
  244.       ClrScr;
  245.       DisplayTitle;
  246.       DisplayItemTitles;
  247.       GotoXY( 1,1 );
  248.       ch := readKey;
  249.    for Test := 1 to 10 do begin
  250.       for RecordNo := 1 to TotalEquipRecord do begin
  251.          DisplayAEquip( RecordNo, EquipPtrArray[RecordNo]^.AData );
  252.          OldPositionX := WhereX; OldPositionY := WhereY;
  253.          DisplayItemContents( RecordNo, EquipPtrArray[RecordNo]^.AData );
  254.          GotoXY( OldPositionX, OldPositionY );
  255.          ch := ReadKey;
  256.       end;
  257.    end;
  258.       window( 1, 1, 80, 25 );
  259.    end;
  260.  
  261. begin { of program }
  262.    AssignFiles( EquipFileName, MaintFileName );
  263.    ReadEquipmentFile( EquipPtrArray, TotalEquipRecord );
  264.    DisplayProcess( EquipPtrArray, TotalEquipRecord );
  265. end.
  266.